import 'package:bxultimate/app/router/router_name.dart';
import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/app/theme/gaps.dart';
import 'package:bxultimate/data/store/config_store.dart';
import 'package:bxultimate/domain/shop/Shop.dart';
import 'package:bxultimate/resources/assets.dart';
import 'package:bxultimate/widgets/mk_load_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

class AppShopItemCard extends StatefulWidget {
  final Shop shop;


  const AppShopItemCard({super.key, required this.shop});

  @override
  State<AppShopItemCard> createState() => _AppShopItemCardState();
}

class _AppShopItemCardState extends State<AppShopItemCard> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: (){
        Get.toNamed(RouterName.shopDetail,arguments: widget.shop.id);
      },
      child: Container(
        padding: EdgeInsets.all(8),
        margin: EdgeInsets.symmetric(vertical: 4),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(10),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            ClipRRect(
                borderRadius: BorderRadius.circular(10),
                child: MkLoadImage(
                  ConfigStore.to.baseFileUrl + widget.shop.shopFacadePhoto!,
                  width: 80,
                  height: 80,
                  fit: BoxFit.cover,
                )),
            Gaps.hGap8,
            Expanded(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Text(
                        '${widget.shop.name}',
                        style:
                            TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
                      ),
                      Row(
                        children: [
                          Icon(
                            Icons.star,
                            size: 13,
                            color: Colors.yellow,
                          ),
                          Text(
                            '4.5分',
                            style: TextStyle(fontSize: 12),
                          ),
                          Gaps.hGap4,
                          Icon(
                            Icons.star,
                            size: 16,
                            color: Colors.yellow,
                          ),
                          Text(
                            '${widget.shop.distance!.toInt()}km',
                            style: TextStyle(fontSize: 12),
                          ),
                        ],
                      )
                    ],
                  ),
                  Gaps.vGap12,
                  Row(
                    children: [
                      TDTag(
                        '最高四星级优惠',
                        theme: TDTagTheme.primary,
                        isOutline: true,
                        size: TDTagSize.small,
                      ),
                      Gaps.hGap8,
                      TDTag(
                        '异性机油壶',
                        theme: TDTagTheme.primary,
                        isOutline: true,
                        size: TDTagSize.small,
                      ),
                    ],
                  ),
                  Gaps.vGap12,
                  Row(
                    children: [
                      Expanded(
                          child: Text(
                        '${widget.shop.address}',
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                            style: TextStyle(fontSize: 12,color:Color(0xFF606266) ),
                      ))
                    ],
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
